package com.atguigu.srb.core.controller.admin;


import com.atguigu.common.results.R;
import com.atguigu.srb.core.pojo.entity.LendReturn;
import com.atguigu.srb.core.service.LendReturnService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 还款记录表 前端控制器
 * </p>
 *
 * @author Atguigu
 * @since 2022-10-24
 */
@RestController
@RequestMapping("/admin/core/lendReturn")
public class AdminLendReturnController {
    @Autowired
    LendReturnService lendReturnService;
    @ApiOperation("查询指定标的的还款计划")
    @GetMapping("/list/{lendId}")
    public R listLendReturns(@PathVariable("lendId")String lendId){
        List<LendReturn> lendReturns = lendReturnService.list(new LambdaQueryWrapper<LendReturn>()
                .eq(LendReturn::getLendId, lendId)
                .orderByAsc(LendReturn::getCurrentPeriod));//使用期数由小到大排序
        return R.success().data("items",lendReturns);
    }
}

